package com.yxw.live_vod_backend_boot.controller;


import com.yxw.live_vod_backend_boot.vo.VodOverviewVo;
import com.yxw.live_vod_backend_facade.dto.AddVodUsageInformationDto;
import com.yxw.live_vod_backend_boot.dto.VodDosageDto;
import com.yxw.live_vod_backend_boot.service.VodBackendService;
import com.yxw.live_vod_backend_boot.vo.VodDosageVo;
import com.yxw.live_vod_facade.dto.*;
import com.yxw.live_vod_facade.vo.OnDemandCommentVO;
import com.yxw.live_vod_facade.vo.PageVodInfoListVO;
import com.yxw.live_vod_facade.vo.VideoReviewVO;
import com.yxw.live_vod_facade.vo.VodSalesRevenueVo;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author liuxin
 * @create 2023-12-1
 * @description 点播相关后台操作
 */
@RestController
@Api(value = "点播相关后台操作", tags = "点播相关后台操作")
@Slf4j
@RequestMapping("/api/backend/vod")
public class VodBackendController {

    @Autowired
    private VodBackendService vodBackendService;
    @PostMapping(value = "/handle")
    @ApiOperation(value = "视频审核处理")
    public BaseResult handle(@RequestBody @Validated VideoReviewHandelDTO dto){
        return  vodBackendService.handle(dto);
    }

    @ApiOperation(value = "查询待审核视频列表")
    @PostMapping(value = "/pageVideoReviews")
    public BaseResult<PageVO<VideoReviewVO>> pageVideoReviews(@RequestBody PageVideoReviewsDTO dto){
        return vodBackendService.pageVideoReviews(dto);
    }

    @ApiOperation(value = "店铺点播作品列表详情查询")
    @PostMapping(value = "/pageVodInfoList")
    public BaseResult<PageVO<PageVodInfoListVO>> pageVodInfoList(@RequestBody PageVodInfoListDto dto){
        return vodBackendService.pageVodInfoList(dto);
    }

    @ApiOperation(value = "查询视频下面的评论和回复")
    @PostMapping(value = "/pageVideoComments")
    public BaseResult<PageVO<OnDemandCommentVO>>  pageVideoComments(@Valid  @RequestBody PageOnDemandCommentDTO dto) {
        return vodBackendService.pageVideoComments(dto);
    }
    @ApiOperation(value = "删除评论")
    @PostMapping(value = "/deleteCommentById")
    public BaseResult  deleteCommentById(@RequestBody Long commentId) {
        return vodBackendService.deleteCommentById(commentId);
    }

    @PostMapping(value = "/deleteVideoByIds")
    @ApiOperation(value = "下架视频")
    public BaseResult deleteVideoByIds(@Validated @RequestBody VideoDeleteDTO dto){
        return vodBackendService.deleteVideoByIds(dto);
    }

    @GetMapping(value = "/getVodUsageInformation")
    @ApiOperation(value = "获取点播视频用量信息")
    public BaseResult<List<VodDosageVo>> getVodUsageInformation(VodDosageDto dto){
        List<VodDosageVo> voList= vodBackendService.getVodUsageInformation(dto);
        return BaseResult.doSuccess(voList,"查询成功");
    }

    @PostMapping(value = "/insertVodUsageInformationByDay")
    @ApiOperation(value = "定时任务查询点播视频用量（天维度）")
    public BaseResult insertVodUsageInformationByDay(@RequestBody AddVodUsageInformationDto dto){
        vodBackendService.insertVodUsageInformationByDay(dto);
        return BaseResult.doSuccess(null,"抽取成功");
    }

    @GetMapping(value = "/getVodOverviewInfo")
    @ApiOperation(value = "查询点播概览信息")
    public BaseResult<VodOverviewVo> getVodOverviewInfo(){
        VodOverviewVo vo=vodBackendService.getVodOverviewInfo();
        return BaseResult.doSuccess(vo,"抽取成功");
    }

    @GetMapping(value = "/getVodSalesRevenue")
    @ApiOperation(value = "查询点播商品带货收入详情")
    public BaseResult<VodSalesRevenueVo> getVodSalesRevenue(@RequestParam Long videoId){
        return vodBackendService.getVodSalesRevenue(videoId);
    }
}
